<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>博客</title>
    <link href="<%=basePath%>bootstrap/css/blog-home.css"/>
    <link href="<%=basePath%>bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="<%=basePath%>bootstrap/js/jquery-2.1.1.js"></script>
</head>
<style>
    input{
        width: 300px;
        height: 45px;
    }
    textarea{
        width: 300px;
        height: 180px;
    }
</style>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="<%=path%>/index.jsp">轻博客</a>
        </div>
        <!--导航链接，表格，和切换其他内容-->
        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav">
                <li><a href="<%=basePath %>user?method=index">首页</a></li>
            </ul>
            <c:if test="${null != user && user.isApplied == 1}">
                <ul class="nav navbar-nav">
                    <li><a href="<%=basePath %>user?method=myblog&userId=${user.id}">我的博客</a></li>
                </ul>
                <ul class="nav navbar-nav">
                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">博客管理<b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="<%=basePath %>article?method=manage&userId=${user.id}"><i class="icon-cog"></i> 博文管理</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=basePath %>category?method=manage&userId=${user.id}"><i class="icon-cog"></i> 分类管理</a></li>
                            <li class="divider"></li>
                            <li><a href="<%=basePath %>comment?method=manage&userId=${user.id}"><i class="icon-cog"></i> 评论管理</a></li>
                        </ul></li>
                </ul>
            </c:if>
            <c:if test="${null==user}">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="Login.jsp" target="_blank">登录</a></li>
                    <li><a href="Register.jsp" target="_blank">注册</a></li>
                </ul>
            </c:if>
            <c:if test="${user!=null}">
                <div class="pull-right">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">欢迎，${user.userName}</a></li>
                        <li><a href="<%=basePath%>user?method=profile&id=${user.id}"><i class="glyphicon glyphicon-cog"></i> 编辑个人信息</a></li>
                        <c:if test="${user.isApplied==1}">
                            <li><a href="<%=basePath%>user?method=bloginfo&userId=${user.id}"><i class="glyphicon glyphicon-cog"></i> 编辑博客信息</a></li>
                        </c:if>
                        <li><a href="<%=path%>/user?method=logout"><i class="glyphicon glyphicon-off"></i> 登出</a></li>
                    </ul>
                    </li>
                    </ul>
                </div>
            </c:if>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav>
<div class="container" style="position: absolute;top: 150px;left: 340px">
    <div class="row col-md-6">
        <form action="<%=basePath %>user?method=apply&userId=${user.id}"  method="post" role="form" class="form-horizontal" name="blog_info_form" id="blog_info_form" onsubmit="return isValidate(blog_info_form)">
            <c:if test="${null != succMsg}">
                <div class="alert alert-success">
                        ${succMsg}
                </div>
                <%
                    request.getSession().removeAttribute("succMsg");
                %>
            </c:if>
            <c:if test="${null != errorMsg}">
                <div class="alert alert-error">
                        ${errorMsg}
                </div>
                <%
                    request.getSession().removeAttribute("errorMsg");
                %>
            </c:if>
            <fieldset>
                <div class="form-group">
                    <label for="blog_name"> 博客名称 </label>
                    <input class="form-controls" name="blog_name"  type="text" value="" id="blog_name">
                </div>
                <div class="form-group">
                    <label for="description"> 博客描述 </label>
                    <input class="form-controls" name="description" type="text" value="" id="description">
                </div>
                <div class="form-group">
                    <label for="annoucement"> 博客公告 </label>
                    <textarea class="form-controls" id="annoucement" name="annoucement" rows="5"></textarea>
                </div>
                <div class="form-group">
                    <button class="btn btn-primary" type="submit" class="">申请</button>
                </div>
            </fieldset>
        </form>
    </div>
</div>
<div class="container" style="position: absolute;bottom: 10px;left: 400px">
    <hr>
    <footer style="text-align: center">
        <div class="row">
            <div class="col-lg-12">
                <p>
                    &middot;网站创建到目前访问人数：<%=(Integer)session.getAttribute("num") %>
                </p>
            </div>
        </div>
    </footer>
</div>
</div>
<div><audio autoplay="autoplay" loop="true"><source src="music/1.mp3"></audio></div>
</body>
<script type="text/javascript">
    function isValidate(blog_info_form) {
        var blog_name = blog_info_form.blog_name.value;
        var description = blog_info_form.description.value;
        var annoucement = blog_info_form.annoucement.value;

        if (blog_name == "" || description == "" || annoucement == "") {
            alert("博客名称，博客描述，博客公告为必填项");
            return false;
        }

        return true;
    }
</script>
</html>